home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / dpmigcc5.zip / RSX / SOURCE / LOADER / LOADER.H < prev    next >
C/C++ Source or Header  |  1994-12-12  |  4KB  |  130 lines

  1. typedef unsigned char    BYTE;
  2. typedef unsigned short    WORD;
  3. typedef unsigned long    DWORD;
  4.  
  5. /* descriptor fields */
  6. #define ACCESS_BIT        1
  7. #define READ_BIT        2
  8. #define WRITE_BIT        2
  9. #define CONFIRMING_BIT        4
  10. #define EXPAND_BIT        4
  11. #define CODE_BIT        8
  12. #define SEGMENT_BIT        16
  13. #define PRESENT_BIT        128
  14. #define AVL_BIT         16
  15. #define DEFAULT_BIT        64
  16. #define BIG_BIT         64
  17. #define GRANULAR_BIT        128
  18. #define DPL_MASK        96
  19. #define TYPE_MASK        15
  20. #define LIMIT_HI_MASK        15
  21.  
  22. #define APP_CODE_SEL        250   /* dpl=3 , read */
  23. #define APP_DATA_SEL        242   /* dpl=3 ,write */
  24.  
  25. #define TYPE_CODE        10
  26. #define TYPE_CONFIRM_CODE    14
  27. #define TYPE_DATA        2
  28. #define TYPE_EXPAND_DATA    6
  29. #define TYPE_286TSS        1
  30. #define TYPE_LDT        2
  31. #define TYPE_BUSY286TSS     3
  32. #define TYPE_286CALLGATE    4
  33. #define TYPE_TASKGATE        5
  34. #define TYPE_286INTGATE     6
  35. #define TYPE_286TRAPGATE    7
  36. #define TYPE_386TSS        9
  37. #define TYPE_BUSY386TSS     11
  38. #define TYPE_386CALLGATE    12
  39. #define TYPE_386INTGATE     14
  40. #define TYPE_386TRAPGATE    15
  41.  
  42. /* *************************************************************** */
  43.  
  44. int    AllocLDT(WORD anzahl,WORD *sel);
  45. int    FreeLDT(WORD);
  46. WORD    SelInc(void);
  47. int    SetBaseAddress(WORD sel,DWORD address);
  48. int    SetLimit(WORD sel,DWORD limit);
  49. int    SetAccess(WORD sel,BYTE access,BYTE extaccess);
  50. WORD    GetCS(void);
  51. WORD    GetDS(void);
  52. int    GetDpmiEntryPoint(DWORD *entry,WORD *para,WORD *flags,WORD *v,BYTE *cpu);
  53. int    GetDpmiHostParagraph(WORD paragr);
  54. int    DpmiEnterProtectedMode(DWORD entry,WORD mode,WORD hostsegm);
  55. int    DosReallocParagraph(int segm, int paragr);
  56. #define DosGetParagraph(x) GetDpmiHostParagraph(x)
  57. int    LockLinRegion(DWORD size,DWORD address);
  58.  
  59. /* *************************************************************** */
  60.  
  61. void    dos_puts(char *name);
  62. int    dos_open(char *name, int mode);
  63. int    dos_close(int handle);
  64. int    dos_read_far(int handle, void far *buffer, int bytes);
  65. int    dos_read(int handle, void * buffer, int bytes);
  66. long    dos_lseek(int handle, long pos, int orgin);
  67. void    far_memcpy(void far *, void far *, int);
  68. void    far_bzero(void far *, int);
  69. void    jmp_to_user(void);
  70. int    npx_installed(void);
  71.  
  72. /* *************************************************************** */
  73.  
  74. #define N_MAGIC(exec) ((exec).a_info & 0xffff)
  75. #define OMAGIC 0x107
  76. #define NMAGIC 0x108
  77. #define ZMAGIC 0x10B
  78.  
  79. #define SEGMENT_SIZE 0x10000L
  80. #define N_TXTADDR(x) SEGMENT_SIZE
  81. #define N_DATADDR(x) (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1)))
  82. #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
  83.  
  84. #define _N_HDROFF(x)    (1024 - sizeof (struct exec))
  85. #define N_TXTOFF(x)    (_N_HDROFF((x)) + sizeof (struct exec))
  86. #define N_DATOFF(x)    (N_TXTOFF(x) + (x).a_text)
  87. #define N_TRELOFF(x)    (N_DATOFF(x) + (x).a_data)
  88. #define N_DRELOFF(x)    (N_TRELOFF(x) + (x).a_trsize)
  89. #define N_SYMOFF(x)    (N_DRELOFF(x) + (x).a_drsize)
  90. #define N_STROFF(x)    (N_SYMOFF(x) + (x).a_syms)
  91.  
  92. typedef struct exec {
  93.     DWORD a_info;     /* Use macros N_MAGIC, etc for access */
  94.     DWORD a_text;     /* length of text, in bytes */
  95.     DWORD a_data;     /* length of data, in bytes */
  96.     DWORD a_bss;      /* length of uninitialized data area for file, in bytes */
  97.     DWORD a_syms;     /* length of symbol table data in file, in bytes */
  98.     DWORD a_entry;    /* start address */
  99.     DWORD a_trsize;   /* length of relocation info for text, in bytes */
  100.     DWORD a_drsize;   /* length of relocation info for data, in bytes */
  101.     } GNUOUT ;
  102.  
  103. struct exe_hdr {
  104.     WORD signatur;
  105.     WORD low;
  106.     WORD high;
  107.     WORD reloc;
  108.     WORD hdr_para;
  109.     };
  110.  
  111. #ifndef NULL
  112. #define NULL (void *)0
  113. #endif
  114.  
  115. /* DOSOPEN : AH = 0x3d , AL = mode , DS:DX name */
  116. /* bits 0-2 */
  117. #define DO_RDONLY    0x00
  118. #define DO_WRONLY    0x01
  119. #define DO_RDWR     0x02
  120. /* bits 4-6 */
  121. #define DO_COMPAT    0x00
  122. #define DO_DENYRW    0x10
  123. #define DO_DENYWR    0x20
  124. #define DO_DENYRD    0x30
  125. #define DO_DENYNO    0x40
  126. /* bit 7 */
  127. #define DO_INHERIT    0x80
  128.  
  129. #define SEEK_SET 0
  130.